package com.fili.gui;

import java.io.*;

/**
 * Created by Claudiu-Florin FILIMON
 * Date: Oct 18, 2006
 * Time: 3:09:14 PM
 * Revision: 0
 */
public class Params implements Serializable
{
    public static String PARAMS_PATH;
    private static Params _this;

    public String[] svnRepo=new String[0];
    public String svnUser="";
    public String svnPass="";
    public boolean svnAuth=false;

    private Params()
    {
        try
        {
            PARAMS_PATH = new File(".").getCanonicalPath()+"/params.dat";
        }
        catch (IOException e)
        {
            e.printStackTrace();
            PARAMS_PATH = "./params.dat";
        }
    }

    public static Params getParams()
    {
        if (_this == null)
            _this = new Params();

        return _this;
    }

    public static void loadParams()
    {
        getParams();
        try
        {
            ObjectInputStream ois = new ObjectInputStream(new FileInputStream(PARAMS_PATH));
            _this = (Params) ois.readObject();
            ois.close();
        }
        catch (IOException e)
        {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
            _this = new Params();
        }
        catch (ClassNotFoundException e)
        {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
            _this = new Params();
        }
    }

    public static void saveParams()
    {
        getParams();
        try
        {
            ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(PARAMS_PATH));
            oos.writeObject(_this);
            oos.flush();
            oos.close();
        }
        catch (IOException e)
        {
            e.printStackTrace();
        }
    }
}
